package com.pattern.flyweight_pattern;

import java.util.HashMap;

/**
 * Created by chen on 2018/3/26.
 * <p>
 * Email 122741482@qq.com
 * <p>
 * Describe:
 */
public class ColorFactory {
    private static final HashMap<String, Color> colorleMap = new HashMap();


    public static Color getColor(String name) {
        Color color1 = (Color)colorleMap.get(name);

        if(color1 == null) {
            System.out.print(name+"  颜色不存在..创建一个放到缓存中..");
            color1= new ColorCache(name);
            colorleMap.put(name, color1);
        }
        return color1;
    }

}
